package com.powergisol.gis.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.powergisol.gis.dto.ExcelTabWall1DTO;
import com.powergisol.gis.entity.TabCoordinateSystem;
import com.powergisol.gis.vo.ExcelInFailedDataVo;
import com.powergisol.gis.vo.TabWall1VO;
import com.powergisol.gis.vo.TaskResultVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class TabWall1Listener extends AnalysisEventListener {

    private final static Pattern NUMBER_PATTERN = Pattern.compile("([+\\-]?[0-9]+[.]?[\\d]*)");

    private TabWall1VO vo;

    //坐标系bean
    TabCoordinateSystem system;


    CacheManager cacheManager;

    //字段值所在列数
    private Integer valueColumn;

    private ExcelTabWall1DTO tabWallDTO;


    public TabWall1Listener() {

    }

    public TabWall1Listener(TabWall1VO vo, TabCoordinateSystem system,
                            CacheManager cacheManager, ExcelTabWall1DTO tabWallDTO) {
        this.vo = vo;
        this.system = system;
        this.cacheManager = cacheManager;
        this.tabWallDTO = tabWallDTO;
    }


    @Override
    public void invoke(Object o, AnalysisContext context) {
        ArrayList data = (ArrayList) o;
        try {
            if (data.isEmpty()) {
                return;
            }
            int j = 0;
            int dataSize = data.size();
            for (int i = 0; i < dataSize; i++) {
                if (j == 1) {
                    return;
                }
                String str = String.valueOf(data.get(i));
                if (StringUtils.isBlank(str)) continue;

                //如果列数存在
                if (null == valueColumn && str.equals("字段值")) {
                    valueColumn = i;
                }
                boolean flag = null != valueColumn && valueColumn < dataSize &&  null != data.get(valueColumn);
                if(!flag){
                    continue;
                }
                switch (str) {
                    case "Hcdm01":
                        vo.setHcdm01(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm02":
                        vo.setHcdm02(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm03":
                        vo.setHcdm03(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm04":
                        vo.setHcdm04(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm05":
                        vo.setHcdm05(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm06":
                        vo.setHcdm06(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "Hcdm07":
                        vo.setHcdm07(String.valueOf(data.get(valueColumn)));
                        j++;
                        break;
                    case "JQZ21":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz21(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;

                    case "JQZ22":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz22(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ23":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz23(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ28":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz28(Integer.valueOf((String.valueOf(data.get(valueColumn)))));
                        }
                        j++;
                        break;
                    case "JQZ25":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz25(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ26":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz26(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ27":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz27(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ29":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz29(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ30":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz30(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ24":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz24(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ31":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz31(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ32":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz32(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "JQZ33":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setJqz33(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "XQS01":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setXqs01(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "XQS02":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setXqs02(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "YQS01":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setYqs01(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    case "YQS02":
                        if(NUMBER_PATTERN.matcher(String.valueOf(data.get(valueColumn))).matches()){
                            vo.setYqs02(Double.parseDouble(String.valueOf(data.get(valueColumn))));
                        }
                        j++;
                        break;
                    default:
                        break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        saveDate(vo);
    }

    private void saveDate(TabWall1VO vo) {
        try{
            if (null ==vo.getJqz21()) {
                dealFail("坐标Xl需为数字");
                return;
            }
            if (null ==vo.getJqz22()) {
                dealFail("坐标Yw需为数字");
                return;
            }
            if (null ==vo.getJqz23()) {
                dealFail("坐标Zh需为数字");
                return;
            }

            vo.setAjqz21(vo.getLon());
            vo.setAjqz22(vo.getLat());
            vo.setAjqz23(vo.getHigh());
            //计算所需值
            Double lon = vo.getLon()*1000+vo.getJqz21();
            Double lat = vo.getLat()*1000+vo.getJqz22();
            Double zh = vo.getHigh()+vo.getJqz23()*0.001;
            vo.setZh(zh);
            //剪力墙柱形状参数(一1，L2，倒T3，Z4，反Z5)
            Integer wallType = vo.getJqz28();
            //剪力墙柱坐标系l轴与建筑物坐标系X轴夹角β
            Integer angle = getAngle(vo.getJqz24());
            Double londCount = 0d;//转换经度前x米坐标值
            Double latdCount = 0d;//转换纬度前y米坐标值

            Double lonuCount = 0d;//转换经度前x米坐标值
            Double latuCount = 0d;//转换纬度前y米坐标值

            Double x1Count = 0d;//转换经度前l正方向剪力墙身长度
            Double x2Count = 0d;//转换纬度前l正方向剪力墙身厚度
            Double y1Count = 0d;//转换经度前w正方向剪力墙身长度
            Double y2Count = 0d;//转换纬度前w正方向剪力墙身厚度

            Double XWD = 0d;//转换后横向下经度
            Double YWD = 0d;//转换后横向下纬度

            Double XL = 0d;//转换后纵向经度
            Double YL = 0d;//转换后纵向纬度

            Double XWU = 0d;//转换后横向上经度
            Double YWU = 0d;//转换后横向上纬度

            Double XQX = 0d;//w正方向剪力墙身经度
            Double YQX = 0d;//w正方向剪力墙身纬度

            Double XQY = 0d;//w正方向剪力梁长度经度
            Double YQY = 0d;//w正方向剪力梁长度纬度


            switch (wallType){
                case 1:
                    switch (angle){
                        case 0:
                            //计算中心点经纬度
                            Double jqz25cc0 = 0d;
                            if(null != vo.getJqz25()){
                                jqz25cc0 = vo.getJqz25();
                            }
                            londCount = (lon + jqz25cc0*0.5)*0.001;
                            latdCount = lat*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = (lon + jqz25cc0 + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(latdCount);
                            }
                            //计算Y方向剪力墙身经纬度
                            Double jqz290 = 0d;
                            if(null != vo.getJqz29()){
                                jqz290 = vo.getJqz29();
                            }
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = (lon + vo.getYqs02()*0.5)*0.001;
                                y2Count = (lat+(vo.getYqs01()+jqz290)*0.5)*0.001;
                                vo.setOxqy(y1Count);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 1:
                            Double jqz25cc1 = 0d;
                            if(null != vo.getJqz25()){
                                jqz25cc1 = vo.getJqz25();
                            }
                            londCount = lon*0.001;
                            latdCount = (lat + jqz25cc1*0.5)*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x2Count = (lat + jqz25cc1 + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(londCount);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat + vo.getYqs02()*0.5)*0.001;
                                Double jqz291 = 0d;
                                if(null != vo.getJqz29()){
                                    jqz291 = vo.getJqz29();
                                }
                                y1Count = (lon - (jqz291 + vo.getYqs01())*0.5)*0.001;
                                vo.setOxqy(y1Count);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 2:
                            Double jqz25cc2 = 0d;
                            if(null != vo.getJqz25()){
                                jqz25cc2 = vo.getJqz25();
                            }
                            londCount = (lon - jqz25cc2*0.5)*0.001;
                            latdCount = lat*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = (lon - jqz25cc2 - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(latdCount);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = (lon - vo.getYqs02()*0.5)*0.001;
                                Double jqz292 = 0d;
                                if(null != vo.getJqz29()){
                                    jqz292 = vo.getJqz29();
                                }
                                y2Count = (lat - (jqz292 + vo.getYqs01())*0.5)*0.001;
                                vo.setOxqy(y1Count);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 3:
                            londCount = lon*0.001;
                            Double jqz25cc3 = 0d;
                            if(null != vo.getJqz25()){
                                jqz25cc3 = vo.getJqz25();
                            }
                            latdCount = (lat - jqz25cc3*0.5)*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x2Count = (lat - jqz25cc3 - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(londCount);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat - vo.getYqs02()*0.5)*0.001;
                                Double jqz293 = 0d;
                                if(null != vo.getJqz29()){
                                    jqz293 = vo.getJqz29();
                                }
                                y1Count = (lon + (jqz293 + vo.getYqs01())*0.5)*0.001;
                                vo.setOxqy(y1Count);
                                vo.setOyqy(y2Count);
                            }
                            break;
                    }
                    break;
                case 2:
                    //计算中心点经纬度
                    switch (angle){
                        case 0:
                            //横向底部经纬度
                            londCount = (lon - vo.getJqz30()*0.5 + (vo.getJqz25()+ vo.getJqz30()*0.5)*0.5)*0.001;
                            latdCount = lat*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //纵向经纬度
                            latuCount = (lat + vo.getJqz26()*0.5)*0.001;
                            lonuCount = lon*0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);
                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x2Count = (lon + vo.getJqz25() + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x2Count);
                                vo.setOyqx(latdCount);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat + vo.getJqz26() + vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(lonuCount);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 1:
                            //横向底部经纬度
                            londCount = lon*0.001;
                            latdCount = (lat - vo.getJqz30()*0.5 + (vo.getJqz25()+ vo.getJqz30()*0.5)*0.5)*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            //纵向经纬度
                            lonuCount = (lon - vo.getJqz26()*0.5)*0.001;
                            latuCount = lat*0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = londCount;
                                x2Count = (lat + vo.getJqz25() + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = latuCount;
                                y2Count = (lon - vo.getJqz26() - vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(y2Count);
                                vo.setOyqy(y1Count);
                            }
                            break;
                        case 2:
                            //横向底部经纬度
                            latdCount = lat*0.001;
                            londCount = (lon + vo.getJqz30()*0.5 - (vo.getJqz25() + vo.getJqz30()*0.5)*0.5)*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //纵向经纬度
                            latuCount = (lat - vo.getJqz26()*0.5)*0.001;
                            lonuCount = lon*0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = latdCount;
                                x2Count = (lon - vo.getJqz25() - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x2Count);
                                vo.setOyqx(x1Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat - vo.getJqz26() - vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(lonuCount);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 3:
                            //横向底部经纬度
                            londCount = lon *0.001;
                            latdCount = (lat + vo.getJqz30()*0.5 - (vo.getJqz25() + vo.getJqz30()*0.5)*0.5)*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //纵向经纬度
                            lonuCount = (lon + vo.getJqz26()*0.5)*0.001;
                            latuCount = lat *0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);
                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = londCount;
                                x2Count = (lat - vo.getJqz25() - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = latuCount;
                                y2Count = (lon + vo.getJqz26() + vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(y2Count);
                                vo.setOyqy(y1Count);
                            }
                            break;
                    }
                    break;
                case 3:
                    //计算中心点经纬度
                    switch (angle){
                        case 0:
                            //T型横梁经纬度
                            londCount = lon *0.001;
                            latdCount = lat *0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);
                            //T型竖梁经纬度
                            lonuCount = lon *0.001;
                            latuCount = (lat + vo.getJqz26()*0.5)*0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x2Count = (lon + vo.getJqz25() + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x2Count);
                                vo.setOyqx(latdCount);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat + vo.getJqz26() + vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(londCount);
                                vo.setOyqy(y2Count);
                            }

                            break;
                        case 1:
                            londCount = lon*0.001;
                            latdCount = lat*0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            lonuCount = (lon - vo.getJqz26()*0.5)*0.001;
                            latuCount = lat *0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = londCount;
                                x2Count = (lat + vo.getJqz25() + vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = latuCount;
                                y2Count = (lon - vo.getJqz26() - vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(y2Count);
                                vo.setOyqy(y1Count);
                            }

                            break;
                        case 2:
                            londCount = lon *0.001;
                            latdCount = lat *0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            lonuCount = lon *0.001;
                            latuCount = (lat - vo.getJqz26()*0.5)*0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);

                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x2Count = (lon - vo.getJqz25() - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x2Count);
                                vo.setOyqx(latdCount);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y2Count = (lat - vo.getJqz26() - vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(londCount);
                                vo.setOyqy(y2Count);
                            }
                            break;
                        case 3:
                            londCount = lon *0.001;
                            latdCount = lat *0.001;
                            vo.setOxwd(londCount);
                            vo.setOywd(latdCount);

                            lonuCount = (lon + vo.getJqz26()*0.5)*0.001;
                            latuCount = lat *0.001;
                            vo.setOxl(lonuCount);
                            vo.setOyl(latuCount);
                            //计算X方向剪力墙身经纬度
                            if(null != vo.getXqs01()&& null != vo.getXqs02()){
                                x1Count = londCount;
                                x2Count = (lat - vo.getJqz25() - vo.getXqs01()*0.5)*0.001;
                                vo.setOxqx(x1Count);
                                vo.setOyqx(x2Count);
                            }
                            //计算Y方向剪力墙身经纬度
                            if(null != vo.getYqs01() && null != vo.getYqs02()){
                                y1Count = latuCount;
                                y2Count = (lon + vo.getJqz26() + vo.getYqs01()*0.5)*0.001;
                                vo.setOxqy(y2Count);
                                vo.setOyqy(y1Count);
                            }

                            break;
                    }
                    break;
                case 4:
                    //计算中心点经纬度
                    switch (angle){
                        case 0:
                            break;
                        case 1:
                            break;
                        case 2:
                            break;
                        case 3:
                            break;
                    }
                    break;
                case 5:
                    //计算中心点经纬度
                    switch (angle){
                        case 0:
                            break;
                        case 1:
                            break;
                        case 2:
                            break;
                        case 3:
                            break;
                    }
                    break;
            }
            tabWallDTO.getWallList().add(vo);
        }catch (Exception e){
            e.printStackTrace();
            dealFail("系统错误,请联系管理员");
        }

    }

    private Integer getAngle(Double angle){
        if(null == angle){
            return 0;
        }
        if(Double.compare(0,angle)==0){
            return 0;
        }else if(Double.compare(90,angle)==0){
            return 1;
        }else if(Double.compare(180,angle)==0){
            return 2;
        }else if(Double.compare(-90,angle)==0){
            return 3;
        }
        return 0;
    }

    //转换单位 (mm 转 m （毫米 转 米）)
    private BigDecimal mmTom(BigDecimal mm) {
        if (mm != null) {
            return mm.divide(new BigDecimal(1000), 10, BigDecimal.ROUND_HALF_UP);
        }
        return null;
    }

    private void dealFail(String msg) {
        List<ExcelInFailedDataVo> listFailed = new ArrayList<>();
        ExcelInFailedDataVo failedDataVo = new ExcelInFailedDataVo();
        failedDataVo.setReason(msg);
        failedDataVo.setRowIndex(vo.getExcelName()+"中sheet "+vo.getSheetName());
        listFailed.add(failedDataVo);
        Cache cache = cacheManager.getCache("cache-data");
        TaskResultVo resultVo = new TaskResultVo();
        resultVo.setListFailed(listFailed);
        cache.put(vo.getSheetName()+vo.getUuid() + "sb", resultVo);
    }


}
